/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gws;

import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.Consumes;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

/**
 * REST Web Service
 *
 * @author Administrator
 */
@Path("gws")
public class GWS {

    @Context
    private UriInfo context;
    
    private static GATE gate;
    
    
    /**
     * Creates a new instance of GWS
     */
    public GWS() {
        
    }

    /**
     * Retrieves representation of an instance of gws.GWS
     * @return an instance of java.lang.String
     */
    @GET
    @Produces("text/html")
    public String getHtml(@QueryParam("q") String query) {
        String response = "";
        if (gate == null)
        {
            gate = new GATE();
            response += "Gate need to init<br>";
        }
        response += "Hello GATE users!<br>";
        if(!query.isEmpty())
        {
            response += "You searched for " + query + "<br>";
            //response += gate.timKiem(query);
        }
        return response;
    }

    /**
     * PUT method for updating or creating an instance of GWS
     * @param content representation for the resource
     * @return an HTTP response with content of the updated or created resource.
     */
    @PUT
    @Consumes("text/html")
    public void putHtml(String content) {
    }
}
